home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / vg-2.03 / jpeg / jpeg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  3.2 KB  |  124 lines

  1. /*
  2.  * jpeg.h
  3.  *
  4.  * Copyright (C) 1991, 1992 Thomas G. Lane.
  5.  * This file is part of the Independent JPEG Group's software.
  6.  * For conditions of distribution and use, see the accompanying README file.
  7.  *
  8.  * This is the central file that's #include'd by all the JPEG .c files.
  9.  * Its purpose is to provide a single place to fix any problems with
  10.  * including the wrong system include files.
  11.  * You can edit these declarations if you use a system with nonstandard
  12.  * system include files.
  13.  */
  14.  
  15.  
  16. #include    <stdio.h>
  17. #include    <stddef.h>
  18. #include    <string.h>
  19. #include    <bool.h>
  20.  
  21. #define EIGHT_BIT_SAMPLES
  22. #define BITS_IN_JSAMPLE    8
  23.  
  24. typedef unsigned char    JSAMPLE;
  25.  
  26. #define MAXJSAMPLE    255
  27. #define CENTERJSAMPLE    128
  28.  
  29. typedef int        JCOEF;
  30.  
  31. #define DCTSIZE        8    /* The basic DCT block is 8x8 samples */
  32. #define DCTSIZE2    64    /* DCTSIZE squared; # of elements in a block */
  33.  
  34. typedef JCOEF JBLOCK[DCTSIZE2];    /* one block of coefficients */
  35.  
  36.  
  37. typedef JCOEF DCTELEM;
  38. typedef DCTELEM DCTBLOCK[DCTSIZE2];
  39.  
  40.  
  41. typedef struct {        /* Basic info about one component */
  42.     short component_id;    /* identifier for this component (0..255) */
  43.     short component_index;    /* its index in SOF or cinfo->comp_info[] */
  44.     short h_samp_factor;    /* horizontal sampling factor (1..4) */
  45.     short v_samp_factor;    /* vertical sampling factor (1..4) */
  46.     short quant_tbl_no;    /* quantization table selector (0..3) */
  47.     short dc_tbl_no;    /* DC entropy table selector (0..3) */
  48.     short ac_tbl_no;    /* AC entropy table selector (0..3) */
  49. } jpeg_component_info;
  50.  
  51.  
  52. /*
  53.  * DCT coefficient quantization tables.
  54.  * Note: the values in a QUANT_TBL are always given in zigzag order.
  55.  */
  56.  
  57. typedef int    QUANT_VAL;
  58.  
  59.  
  60. #define NUM_QUANT_TBLS      4    /* quantization tables are numbered 0..3 */
  61. #define NUM_HUFF_TBLS       4    /* Huffman tables are numbered 0..3 */
  62. #define MAX_COMPS_IN_SCAN   4    /* JPEG limit on # of components in one scan */
  63. #define MAX_SAMP_FACTOR     4    /* JPEG limit on sampling factors */
  64. #define MAX_BLOCKS_IN_MCU   10    /* JPEG limit on # of blocks in an MCU */
  65.  
  66. /*
  67.  * A Huffman coding table
  68.  */
  69. typedef struct huff_code
  70. {
  71.     long        maxcode;
  72.     unsigned char    *codeptr;
  73. } HUFF_CODE;
  74.  
  75. typedef struct
  76. {    
  77.     HUFF_CODE        huff_code[18];
  78.     unsigned char    huffval[256];
  79. } HUFF_TBL;
  80.  
  81. typedef struct
  82. {
  83.     QUANT_VAL        q[DCTSIZE2];
  84.  
  85. } QUANT_TBL;
  86.  
  87. typedef struct jpeg_tables
  88. {
  89.     HUFF_TBL    dc_huff_table[NUM_HUFF_TBLS];
  90.     HUFF_TBL    ac_huff_table[NUM_HUFF_TBLS];
  91.     QUANT_TBL    quant_table[NUM_QUANT_TBLS];
  92. } JPEG_TABLES;
  93.  
  94. typedef struct dblock_info
  95. {
  96.     JBLOCK    *coeff_data;
  97.     HUFF_TBL    *dc_table;
  98.     HUFF_TBL    *ac_table;
  99.     JCOEF    *dc_prediction;
  100.     QUANT_TBL    *quant_table;
  101. } DBLOCK_INFO;
  102.  
  103. /* Working data for decompression */
  104.  
  105. struct decompress_info_struct
  106. {
  107.     long image_width;    /* overall image width */
  108.     long image_height;    /* overall image height */
  109.  
  110.     short data_precision;    /* bits of precision in image data */
  111.  
  112.     short num_components;    /* # of color components in JPEG image */
  113.     jpeg_component_info comp_info[MAX_COMPS_IN_SCAN];
  114.     short comps_in_scan;    /* # of JPEG components input this time */
  115.     jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
  116. };
  117.  
  118. typedef struct decompress_info_struct * decompress_info_ptr;
  119.  
  120. #define RST0    0xD0        /* RST0 marker code */
  121.  
  122. extern int    jpegGetByte(FILE *);
  123. extern int    jpegGetWord(FILE *);
  124.